Class MyEventComparator

  • Direct Known Subclasses:
    MyEventAttendeesComparator, MyEventDateComparator

    public abstract class MyEventComparator
    extends java.lang.Object
    This class represents the concept of comparison of two events. It has a single abstract method that is to be implemented by concrete subclasses which implement concrete modes of comparison, e.g. by attendees, by date or other.
    Since:
    ExerciseSheet04
    Version:
    1
    Author:
    Jonas Altrock (ew20b126@technikum-wien.at)
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract int compare​(Event e1, Event e2)
      Compares two events.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MyEventComparator

        public MyEventComparator()
    • Method Detail

      • compare

        public abstract int compare​(Event e1,
                                    Event e2)
        Compares two events.

        The result of the comparison of two events is a measure of "distance" between the tow. Distance is not literal (spatial) distance but more generally the difference between the two measured in some unit. If the two events are equal in a certain sense their distance is zero, if the first argument is smaller than the second (again, in the sense of the (concrete) comparator) their distance is negative, positive otherwise.

        Example: compare two events by date
        Event 1 (e1): March 10, 1979
        Event 2 (e2): April 1, 2000
        Calling compare of a by-date-comparator: compare(e1,e2) would return a negative number (since e1 is before e2)

        Comparators may choose to handle comparison of null tracks but are not forced to.

        Parameters:
        e1 - the one event to compare
        e2 - the other event to compare
        Returns:
        a measure of the distance between e1 and e2 in the sense of the comparator